<?php
	/**
	 * Added by Thai
	 * Init Shopnmatch data for affliatenetwork
	 */
	error_reporting(E_ALL ^ E_NOTICE);
	
	set_include_path(PATH_SEPARATOR . dirname(dirname(dirname(realpath(__FILE__)))) . '/' . 'classes/' . 
					 PATH_SEPARATOR . dirname(realpath(__FILE__)) .  
					 PATH_SEPARATOR . get_include_path());
	define('SNM_APP', dirname(dirname(dirname(realpath(__FILE__)))));
	
	require_once(SNM_APP . '/includes/connect.php');
	require_once(SNM_APP . '/includes/functions.php');
	require_once(SNM_APP . '/includes/head.inc.php');
	require_once(SNM_APP . '/includes/fixlist.inc.php');
	// require template class
	include_once(SNM_APP . "/classes/xtpl/xtemplate.class.php");
	
	XTemplate::$baseDir = SNM_APP; 
	// start content boxes
	$snmINSTALLDIR  = $installDir['value'];
	$snmSKIN = $configSkin['value'];
		
	$snmgetConfigTitle = mysql_query("SELECT * FROM affiliSt_config WHERE name = 'adWebTitle'");
	$snmconfigTitle = mysql_fetch_assoc($snmgetConfigTitle);
	$snmgetLogoImage = mysql_query("SELECT * FROM affiliSt_config WHERE name = 'adLogo'");
	$snmlogoImage = mysql_fetch_assoc($snmgetLogoImage);
	$snmgetAltTag = mysql_query("SELECT * FROM affiliSt_config WHERE name = 'adLogoAlt'");
	$snmaltTag = mysql_fetch_assoc($snmgetAltTag);
	if ($snmlogoImage['value'] == NULL) {
		$snmLogo = '<h1>' . $snmaltTag['value'].'</h1>';
	} else {
		$snmLogo = '<img src="'.$snmlogoImage['value'].'" alt="'.$snmaltTag['value'].'" align="left" />';
	}
	
	$snmgetConfigStrap = mysql_query("SELECT * FROM affiliSt_config WHERE name = 'adWebStrap'");
	$snmconfigStrap = mysql_fetch_assoc($snmgetConfigStrap);
	
	// add page links
	include(SNM_APP . "/includes/pagelinkstop.inc.php");
	
	$snmPAGELINKSTOP = $box_content;
	$snmHOMEPAGELI = topNavOff;
	$snmHOMEPAGELINK = '"topLinkOff" style="color:#ffffff;';
	include(SNM_APP . "/includes/pagelinkstopsub.inc.php");
	$snmPAGELINKSTOPSUB = $box_content;
	include(SNM_APP . "/includes/pagelinksfoot.inc.php");
	$snmFOOTLINKS = $box_content;
	
	// add search
	include(SNM_APP . "/includes/search.inc.php");
	$snmSEARCHPROD = $box_content;
	
		// indicate is the user has loged in or not
	include_once SNM_APP . '/includes/models/Auth.php';
	$auth = Auth::getInstance();
	if(isset($_SESSION['AFFILIATEID'])){
		$snmlogedInAffliate = true;
	} else { 
		/**
		 * @todo check if affliatenetwork was logged in
		 */
		$snmnotLogedInAffliate = true;
	}